package com.ishuangmu.util;

import java.io.FileNotFoundException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.github.stuxuhai.jpinyin.PinyinException;
import com.github.stuxuhai.jpinyin.PinyinFormat;
import com.github.stuxuhai.jpinyin.PinyinHelper;

public class pinyin {
	public static void main(String[] args) throws PinyinException, FileNotFoundException {
		String val="%^&*()ad[]ad12阿萨德拉斯婕拉23 1";
		System.out.println("val:"+val);
		String regEx="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]"; 
		Pattern p = Pattern.compile(regEx); 
		Matcher m = p.matcher(val);
		String title=PinyinHelper.convertToPinyinString(m.replaceAll("").trim(),"", PinyinFormat.WITHOUT_TONE);
		System.out.println(title);
		
	}
	
	
	public String jpinyin(String val) throws Exception{
		String regEx="[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？]"; 
		Pattern p = Pattern.compile(regEx); 
		Matcher m = p.matcher(val);
		String title=PinyinHelper.convertToPinyinString(m.replaceAll("").trim(),"", PinyinFormat.WITHOUT_TONE);
		return title;
	}
	
}
